package cn.app.android.sichuanxiaoke.com.xiaokeapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import cn.app.android.sichuanxiaoke.com.xiaokeapp.R;

/**
 * Created by weian on 2017/8/18.
 */

public class MyTitleAdapter extends BaseAdapter {
    private Context context;
    private List<String > titles;
    private LayoutInflater inflater;
    public MyTitleAdapter(Context context, List<String> titles) {
        this.context = context;
        this.titles = titles;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return titles.size();
    }

    @Override
    public Object getItem(int i) {
        return titles.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }
    class ViewHolder {
        private TextView tv1;
    }
    ViewHolder holder = null;
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view==null)
        {
            view = inflater.inflate(R.layout.classify_list_item_lift,null);
            holder = new ViewHolder();
            holder.tv1 = (TextView) view.findViewById(R.id.title_name);
            view.setTag(holder);
        }else {
            holder = (ViewHolder) view.getTag();
        }
        holder.tv1.setText(titles.get(i));
        return view;
    }
}
